import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '../views/HomePage.vue'
import IndexPage from '@/views/IndexPage.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      component: IndexPage,
      children: [
        { path: '', name: 'home', component: HomePage },
        {
          path: '/template/:id',
          name: 'templateDetail',
          component: () => import('../views/TemplateDetail.vue')
        }
      ]
    },
    {
      path: '/editor/:id?',
      name: 'editor',
      component: () => import('../views/PosterEditor.vue'),
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/LoginPage.vue'),
    }
  ],
})

export default router
